<?php 
session_start();
include_once '../config.php';
list($usrID,$recID,$lastID)=array(intval($_SESSION['usrID']),intval($_GET['recID']),intval($_POST['lastID']));
$res=$pdo->query("select c.chatID,c.msg,concat(u.lname,' ',u.fname) as name from (chat c join usr u on u.usrID) where u.usrID=c.usrID and c.usrID=$recID and c.recID=$usrID and c.chatID > $lastID");//unix_timestamp()// and c.seen=0
header("Content-type: application/json");
echo json_encode($res->fetchAll(PDO::FETCH_ASSOC));
?>